// <copyright file="MainPage.xaml.cs" company="Microsoft">
// Copyright Microsoft. All rights reserved.
// </copyright>
// <author>CONTOSO\Administrator</author>
// <date>2011-03-19 19:07:51Z</date>
namespace SP2010.Hive.Resx.Silverlight.SilverlightApplication1
{
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Net;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Documents;
  using System.Windows.Input;
  using System.Windows.Media;
  using System.Windows.Media.Animation;
  using System.Windows.Shapes;
  using Microsoft.SharePoint.Client;

  public partial class MainPage : UserControl
  {
    private ClientContext ctx;

    public MainPage()
    {
      InitializeComponent();

      // Get SharePoint List after page loads
      this.Loaded += MainPage_Loaded;
    }

    private void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
      // Load client OM assemblies
      LoadClientOM loadClientOM = new LoadClientOM(delegate { LoadData(); });
      loadClientOM.Run();
    }

    private void LoadData()
    {
      // Get Client Context
      ctx = ClientContext.Current;

      if (ctx != null) 
      {
        // ctx is null if we are not in SharePoint
        // Get data from SharePoint client OM
        // List dataList = ctx.Web.Lists.GetByTitle("[listname]");        
      }
    }
  }
}

